﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace IWMAG.Core.EnhancedProperties
{
    public sealed class UniqueIdentifier
    {
        private UniqueIdentifier(string seed = null)
        {
            
            if (string.IsNullOrWhiteSpace(seed))
            {
                seed = Guid.NewGuid().ToString();
            }

            _hashCode = seed.GetHashCode();

        }

        private readonly int _hashCode;
        public override int GetHashCode()
        {
            return _hashCode;
        }

        public override string ToString()
        {
            return _hashCode.ToString();
        }

        public override bool Equals(object obj)
        {
            if (!(obj is UniqueIdentifier))
            {
                return false;
            }

            var t = obj as UniqueIdentifier;
            return t._hashCode == this._hashCode;
        }

        internal static UniqueIdentifier CreateNew()
        {
            return new UniqueIdentifier();
        }
    }
}
